(define tolerance 0.00001)

(define (average-damp f)
  (lambda (x)
    (/ (+ x (f x)) 2)))

(define f
  (lambda (x)
    (/ (log 1000) (log x))))

(define (fixed-point f first-guess)
  (define (close-enough? v1 v2)
    (< (abs (- v1 v2)) tolerance))
  (define (print step x)
    (newline)
    (display step)
    (display " > ")
    (display x))
  (define (try guess step)
    (let ((next (f guess)))
     (print step next)
     (if (close-enough? guess next)
       next
       (try next (+ step 1)))))
  (try first-guess 0))

(fixed-point f 1.1)
(fixed-point (average-damp f) 1.1)
